{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "65b4d824-aa2f-4bdc-bcb6-95ce6185052f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['zero', 'constant', 'symmetric', 'periodic', 'smooth', 'periodization', 'reflect', 'antisymmetric', 'antireflect']\n"
     ]
    }
   ],
   "source": [
    "import pywt\n",
    "import numpy\n",
    "def format_array(a):\n",
    "    a = numpy.where(numpy.abs(a) < 1e-5, 0, a)\n",
    "    return numpy.array2string(a, precision=5, separator=' ', suppress_small=True)\n",
    "print(pywt.Modes.modes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "227c8682-815c-4e61-9703-10d462a5abc1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mode: 0 (zero)\n",
      "Mode: 2 (constant)\n",
      "Mode: 1 (symmetric)\n",
      "Mode: 6 (reflect)\n",
      "Mode: 4 (periodic)\n",
      "Mode: 3 (smooth)\n",
      "Mode: 5 (periodization)\n"
     ]
    }
   ],
   "source": [
    "x = [1, 2, 1, 5, -1, 8, 4, 6]\n",
    "for mode_name in ['zero', 'constant', 'symmetric', 'reflect', 'periodic', 'smooth', 'periodization']:\n",
    "    mode = getattr(pywt.Modes, mode_name)\n",
    "    cA, cD = pywt.dwt(x, 'db2', mode)\n",
    "    print(\"Mode: %d (%s)\" % (mode, mode_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "48b882ff-9feb-47f3-b56b-56b05f7e9153",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1.76776695 1.73309178 3.40612438 6.32928585 7.77817459]\n",
      "[-0.61237244 -2.15599552 -5.95034847 -1.21545369  1.22474487]\n",
      "[ 1.  2.  1.  5. -1.  8.  4.  6.]\n"
     ]
    }
   ],
   "source": [
    "cA, cD = pywt.dwt(x, 'db2')\n",
    "print(cA)\n",
    "print(cD)\n",
    "print(pywt.idwt(cA, cD, 'db2'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b3fe76da-48c3-4bf1-8594-c1f706b84181",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1.76776695 1.73309178 3.40612438 6.32928585 7.77817459]\n",
      "[-0.61237244 -2.15599552 -5.95034847 -1.21545369  1.22474487]\n",
      "[ 1.  2.  1.  5. -1.  8.  4.  6.]\n"
     ]
    }
   ],
   "source": [
    "cA, cD = pywt.dwt(x, 'db2', mode='symmetric')\n",
    "print(cA)\n",
    "print(cD)\n",
    "print(pywt.idwt(cA, cD, 'db2'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b9162d4-a83b-461b-a761-5ad12d5840df",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
